import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/17 16:08
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int findClosestNumber(int[] nums) {
        Arrays.sort(nums);
        int ans = 0, min = Integer.MAX_VALUE;
        for (int r = 0; r < nums.length; r++) {
            if (nums[r] < 0) {
                ans = nums[r];
                min = Math.min(min, -nums[r]);
            }else if (nums[r] == 0) {
                return 0;
            }else {
                if (nums[r] <= min) {
                    min = nums[r];
                    ans = nums[r];
                }else {
                    break;
                }
            }
        }
        return ans;
    }
}
